const mongoose = require('mongoose');

const options = {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useFindAndModify:false,  // 消除警告
    autoIndex: false, // 是否自动建立索引
    reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
    reconnectInterval: 500, // Reconnect every 500ms
    poolSize: 10, // Maintain up to 10 socket connections
    // If not connected, return errors immediately rather than waiting for reconnect
    bufferMaxEntries: 0
};
mongoose.connect('mongodb://localhost:27017/yang-ping-server',options);
const conn = mongoose.connection;

// 绑定连接完成时的监听
conn.on('connected',function(){
    console.log('数据库连接成功!')
})
